// run: $exec < input
#include <iostream>
#include <string>

long long const maxn = 100007;
long long const inf = 1000000001;

long long a[maxn];
long long n, k;

bool inrange(long long x)
{
	return -inf < x && x < inf;
}

int main()
{
	std::cin >> n >> k;
	for (long long i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;
		if (s[0] == '?') a[i] = inf;
		else a[i] = std::stoi(s);
	}
	for (long long i = 0; i < k; i++) {
		long long prev = -inf, count = 0, j = i;
		for (; j < n; j += k) {
			if (a[j] == inf) count++;
			else {
				if (a[j] <= prev) {
					std::cout << "Incorrect sequence\n";
					return 0;
				}
				if (prev == -inf) {
					if (!count) { prev = a[j]; continue; }
					long long t = (count - 1) / 2;
					if (a[j] <= t) t = a[j] - 1;
					for (long long tj = j - k; count; count--, tj -= k)
						a[tj] = t--;
				} else {
					if (!count) { prev = a[j]; continue; }
					long long l = a[j] - prev - 1;
					if (l < count) {
						std::cout << "Incorrect sequence\n";
						return 0;
					}
					long long t = (count - 1) / 2;
					long long t1 = -t;
					if (!(count & 1)) t++;
					if (a[j] <= t) t = a[j] - 1;
					else if (prev >= t1) t = prev + count;
					for (long long tj = j - k; count; count--, tj -= k)
						a[tj] = t--;
				}
				prev = a[j];
			}
		}
		if (count) {
			j -= k;
			if (prev == -inf) {
				long long t = (count - 1) / 2;
				for (long long tj = j; count; count--, tj -= k)
					a[tj] = t--;
			} else {
				long long t = (count - 1) / 2;
				long long t1 = -t;
				if (!(count & 1)) t++;
				if (prev >= t1) t = prev + count;
				for (long long tj = j; count; count--, tj -= k)
					a[tj] = t--;
			}
			prev = a[j];
		}
	}

	for (long long i = 0; i < n; i++)
		std::cout << a[i] << ' ';
	std::cout << '\n';

	/*
	long long sum = 0;
	for (int i = 0; i < n; i++)
		sum += a[i] < 0 ? -a[i] : a[i];
	std::cout << sum << '\n';
	*/
}

